package com.badshun.apkextractor;

import android.app.*;
import android.os.*;
import android.content.pm.*;
import java.util.*;
import android.widget.*;
import android.view.*;
import android.content.*;
import android.graphics.drawable.*;
import android.graphics.*;
import android.view.View.*;

public class MainActivity extends Activity {
	private FragmentManager fragmentManager;

	private TextView userTv, systemTv;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		fragmentManager = getFragmentManager();

		changeFragment(R.id.app_content, new UserAppFragment());
		
		userTv = findViewById(R.id.user_tv);
		userTv.setTextColor(Color.BLACK);
		userTv.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View view) {
				cleanTvStyle();
				userTv.setBackgroundResource(R.drawable.tab_background);
				userTv.setTextColor(Color.BLACK);

				changeFragment(R.id.app_content, new UserAppFragment());
			}
		});

		systemTv = findViewById(R.id.system_tv);
		systemTv.setTextColor(Color.GRAY);
		systemTv.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View view) {
				cleanTvStyle();
				systemTv.setBackgroundResource(R.drawable.tab_background);
				systemTv.setTextColor(Color.BLACK);

				changeFragment(R.id.app_content, new SystemAppFragment());
			}
		});
	}

	private void cleanTvStyle() {
		userTv.setBackgroundResource(R.drawable.none);
		userTv.setTextColor(Color.GRAY);

		systemTv.setBackgroundResource(R.drawable.none);
		systemTv.setTextColor(Color.GRAY);
	}

	private void changeFragment(int id, Fragment fragment) {
		FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
		fragmentTransaction.replace(id, fragment);
		fragmentTransaction.commit();
	}

}
